﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Navigation;
using System.Xml.Linq;
using System.IO;
using System.Globalization;
using System.Windows.Data;
using Infragistics.Controls.Charts;

namespace StartupSolution.Views.Sparkline
{
    public partial class Sparkline : Page
    {
        public Sparkline()
        {
            InitializeComponent();
        }

        // Executes when the user navigates to this page.
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
        }

        private void CheckBoxRange_Click(object sender, RoutedEventArgs e)
        {
            CheckBox chkBox = this.CheckBoxRange as CheckBox;
            if (chkBox == null) return;

            if (chkBox.IsChecked == true)
            {
                this.xamSparkline1.NormalRangeVisibility = System.Windows.Visibility.Visible;
            }
            else
            {
                this.xamSparkline1.NormalRangeVisibility = System.Windows.Visibility.Collapsed;
            }
        }

        private void ComboBoxChartType_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ComboBox cb = this.ComboBoxChartType as ComboBox;
            if (cb == null) return;

            if (this.xamSparkline1 == null) return;

            switch (cb.SelectedIndex)
            {
                case 0:
                    this.xamSparkline1.DisplayType = SparklineDisplayType.Line;
                    break;
                case 1:
                    this.xamSparkline1.DisplayType = SparklineDisplayType.Area;
                    break;
                case 2:
                    this.xamSparkline1.DisplayType = SparklineDisplayType.Column;
                    break;
                case 3:
                    this.xamSparkline1.DisplayType = SparklineDisplayType.WinLoss;
                    break;
            }
        }

        private void ComboBoxTrendlines_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ComboBox cb = this.ComboBoxTrendlines as ComboBox;
            if (cb == null) return;

            if (this.xamSparkline1 == null) return;

            switch (cb.SelectedIndex)
            {
                case 0:
                    this.xamSparkline1.TrendLineType = Infragistics.Controls.Charts.TrendLineType.CubicFit;
                    break;
                case 1:
                    this.xamSparkline1.TrendLineType = Infragistics.Controls.Charts.TrendLineType.CumulativeAverage;
                    break;
                case 2:
                    this.xamSparkline1.TrendLineType = Infragistics.Controls.Charts.TrendLineType.ExponentialAverage;
                    break;
                case 3:
                    this.xamSparkline1.TrendLineType = Infragistics.Controls.Charts.TrendLineType.ExponentialFit;
                    break;
                case 4:
                    this.xamSparkline1.TrendLineType = Infragistics.Controls.Charts.TrendLineType.LinearFit;
                    break;
                case 5:
                    this.xamSparkline1.TrendLineType = Infragistics.Controls.Charts.TrendLineType.LogarithmicFit;
                    break;
                case 6:
                    this.xamSparkline1.TrendLineType = Infragistics.Controls.Charts.TrendLineType.ModifiedAverage;
                    break;
                case 7:
                    this.xamSparkline1.TrendLineType = Infragistics.Controls.Charts.TrendLineType.None;
                    break;
                case 8:
                    this.xamSparkline1.TrendLineType = Infragistics.Controls.Charts.TrendLineType.PowerLawFit;
                    break;
                case 9:
                    this.xamSparkline1.TrendLineType = Infragistics.Controls.Charts.TrendLineType.QuadraticFit;
                    break;
                case 10:
                    this.xamSparkline1.TrendLineType = Infragistics.Controls.Charts.TrendLineType.QuarticFit;
                    break;
                case 11:
                    this.xamSparkline1.TrendLineType = Infragistics.Controls.Charts.TrendLineType.QuinticFit;
                    break;
                case 12:
                    this.xamSparkline1.TrendLineType = Infragistics.Controls.Charts.TrendLineType.SimpleAverage;
                    break;
                case 13:
                    this.xamSparkline1.TrendLineType = Infragistics.Controls.Charts.TrendLineType.WeightedAverage;
                    break;
            }
        }
    }
}
